@isTest
private class MeasureCalcHandlerTest {
    static testMethod void testMethod1() {

       
        //客户1
        Account acc = TestUtils.createAccount();
        acc.Level__c = '三级甲等';
        insert acc;

        //业务机会1
        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = acc.Id;
        opp.CooperationMode__c = '整体配送';
        insert opp;

        Test.startTest();

        

        //产品1
        Product__c p1 = TestUtils.createProduct();    
        p1.Category1__c = '微生物';
        p1.Category0__c = '仪器';
        p1.Brand__c = '迈克';
        
        Product__c p2 = TestUtils.createProduct();
        p2.Name = 'Test1';
        p1.Category0__c = '试剂';
        p2.Category1__c = '免疫';   
        Product__c p3 = TestUtils.createProduct(); 
        p3.Name = 'Test2';   
        p3.Category1__c = '生化';
        p3.Category0__c = '仪器';     
        insert new Product__c[] {p1, p2, p3};


        //测算信息1
        Measure_Calculate__c mc = new Measure_Calculate__c(Opportunity__c = opp.Id);
        insert mc;
        Measure_Calculate__c mc1 = new Measure_Calculate__c(Opportunity__c = opp.Id,Status__c = '审批成功',IsActive__c=true);
        insert mc1;

     


        //测算信息产品1
        Measure_Calculate_Product__c mcp1 = new Measure_Calculate_Product__c(Product__c = p1.Id, Measure_Calculate__c = mc.Id);
        Measure_Calculate_Product__c mcp2 = new Measure_Calculate_Product__c(Product__c = p2.Id, Measure_Calculate__c = mc.Id);
        insert new Measure_Calculate_Product__c[] {mcp1, mcp2};

        mc.Status__c ='审批成功';
        update mc;
        
       

        opp = [select ProjectType__c from Opportunity where Id = :opp.Id];

        mc = [select IsActive__c from Measure_Calculate__c where Id = :mc.Id];
        System.assertEquals(true, mc.IsActive__c);
        mc1= [select IsActive__c from Measure_Calculate__c where Id = :mc1.Id];
        System.assertEquals(false, mc1.IsActive__c);
       // delete mc;


    }

    
}